<?php

class Log extends BaseLog {
    public function getUserString(){
	return sfGuardUserPeer::retrieveByPK($this->getUserId())->getUsername();
    }
    public function getGuardString(){
	return sfGuardUserPeer::retrieveByPK($this->getGuardId())->getUsername();
    }
    public function getTypeString(){
	return TypeJourPeer::retrieveByPK($this->getTypeId())->getLibelle();
    }
    public function getTotalJournee() {
	$heures = (int)($this->total_journee / 60) ;
	$minutes = $this->total_journee % 60;
	return ($heures < 10 ? '0'. $heures : $heures) . "h" . ($minutes < 10 ? '0'.$minutes : $minutes);
    }
    public function calTotalJournee($nul = null) {
	$tempsPresence = floor($this->getObjDateDepart()->getDifference($this->getObjDateArrivee())/60);
	$tempsPause = $this->getTempsPause() ;
	if($tempsPresence < $tempsPause)
	    return 0 ;
	$this->totalJournee = $tempsPresence - $tempsPause ;
    }
    public function getObjDateArrivee() {
	if(TypeJourPeer::retrieveByPK($this->getTypeId())->isOnlyDuree())
	    return null ;
	if( $this->getHeureArrivee() )
	    return new clDate($this->getHeureArrivee());
    }

    public function getObjDateDepart() {
	if(TypeJourPeer::retrieveByPK($this->getTypeId())->isOnlyDuree())
	    return null ;
	if( $this->getHeureDepart() )
	    return new clDate($this->getHeureDepart());
    }
}
